package com.aaa.marketing.service.impl;/**
 * Date:2023/3/2
 * Author：臣哥哥
 * Description:
 */

import com.aaa.entity.AdvertisePosition;
import com.aaa.marketing.dao.AdvertisePositionDao;
import com.aaa.marketing.service.AdvertisePositionService;
import com.aaa.vo.Result;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author     ：Xiaochen
 * @date       ：Created in 2023/3/2 11:46
 * @description：
 * @modified By：
 * @version:
 */
@Service
public class AdvertisePositionServiceImpl implements AdvertisePositionService {
    @Autowired
    private AdvertisePositionDao advertisePositionDao;
    @Override
    public Result selectAll(Integer currentPage, Integer pageSize, AdvertisePosition advertisePosition) {
        PageHelper.startPage(currentPage,pageSize);
        List<AdvertisePosition> advertisePositions = advertisePositionDao.selectAll(advertisePosition);
        PageInfo<AdvertisePosition> advertisePositionPageInfo = new PageInfo<>(advertisePositions);
        return new Result(2000,"成功",advertisePositionPageInfo);
    }

    @Override
    public Result update(AdvertisePosition advertisePosition) {
        int i = advertisePositionDao.updateById(advertisePosition);
        return new Result(2000,"成功",i);
    }

    @Override
    public Result delete(Integer id) {
        int i = advertisePositionDao.deleteById(id);
        return new Result(2000,"成功",i);
    }

    @Override
    public Result insert(AdvertisePosition advertisePosition) {
        int insert = advertisePositionDao.insert(advertisePosition);
        return new Result(2000,"成功",insert);
    }

    @Override
    public Result selectCount(Integer id) {
        return new Result(2000,"成功",advertisePositionDao.selectByCount(id));
    }
}